﻿@{
    ViewBag.Title = "财务修改";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section HeadIncluder
{
    <link href='@Url.Content("~/Content/public.css")' type="text/css" rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")' type="text/css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href=@Url.Content("~/Scripts/skins/default.css") />
    <script type="text/javascript" src=@Url.Content("~/Scripts/lhgdialog.min.js")></script>

}
<div class="content" onkeydown="EnterClick(event.keyCode)">
    <div class="ss_box list_tble" style="margin-top: 20px;">
        <div class="s_box1">
            <table class="s_tble ">
                <tr>
                    <td class="aR">流程标题/序号:</td>
                    <td class="aL" colspan="2">
                        <input id="txtAppName" type="text" name="AppName" />
                    </td>
                    <td class="aR">单据类型:</td>
                    <td class="aL" colspan="2">
                        <select id="dpProcessList" name="ProcessList">
                            <option value="" selected="selected">全部</option>
                            @{
                                IList<FCDB.Entity.WfProcess> list = ViewBag.ProcessList as IList<FCDB.Entity.WfProcess>;
                                foreach (var item in list)
                                {
                                    <option value="@item.ProcessGUID">@item.ProcessName</option>
                                }
                            }
                        </select>
                    </td>
                    <td class="aR">发送时间:</td>
                    <td class="aL">
                        <input id="txtStartDate" type="text" />到<input id="txtEndDate" type="text" />
                    </td>
                </tr>
                <tr>
                    <td class="aR">创建人:</td>
                    <td class="aL">
                        <input id="txtUsersName" type="text" name="UsersName" disabled="disabled" style="width:120px;" />
                        <input type="hidden" id="txtUsersID" name="txtUsersID" />
                    </td>
                    <td class="aL"><span class="btn_s btn_c1"><a href="javascript:void(0)" onclick="addUsers()">添加</a></span></td>
                    <td class="aR">创建部门:</td>
                    <td class="aL">
                        <input id="txtUsersDepartment" type="text" name="UsersDepartment" disabled="disabled" style="width:120px;" />
                        <input type="hidden" id="txUsersDepartmentID" name="txtUsersDepartmentID" />
                    </td>
                    <td class="aL">
                        <span class="btn_s btn_c1">
                            <a href="javascript:void(0)" onclick="SelectDeparment(txUsersDepartmentID,txtUsersDepartment)">选择部门</a>
                        </span>
                    </td>
                    <td class="aL" colspan="2"><span class="btn_s btn_c1"><a href="javascript:void(0)" onclick="onRefresh()">查找</a></span></td>
                </tr>
            </table>
        </div>
    </div>
    <div id="container" style="margin-right: 10px;">
        <div id="divGrid" style="width: 100%; height: 100%;">
            <table id="grid">
                <tr>
                    <th>审批序号</th>
                    <th>标题</th>
                    <th>步骤</th>
                    <th>拟稿人</th>
                    <th>拟稿时间</th>
                    <th>发送人</th>
                    <th>发送时间</th>
                </tr>
            </table>
            <a></a>
        </div>
    </div>

</div>
<script id="rowTemplate" type="text/x-kendo-tmpl">
    <tr>
        <td><a href="javascript:void(0)" onclick="onProcessClick('#: ProcessGUID #','#: ProcessInstanceID #','#: ActivityGUID #','#: ReadyTaskType #')">#: AppInstanceID #  <i style="color:red">#: isRed # </i></a></td>
        <td><a href="javascript:void(0)" onclick="onProcessClick('#: ProcessGUID #','#: ProcessInstanceID #','#: ActivityGUID #','#: ReadyTaskType #')">#: AppName #</a></td>
        <td>#: ActivityName #</td>
        <td>#: AppInstanceCreateUserName #</td>
        <td>#: AppInstanceCreateTime #</td>
        <td>#: CreatedByUserName #</td>
        <td>#: CreatedDateTime #</td>
    </tr>
</script>
<script type="text/javascript">
    function onProcessClick(ProcessGUID, ProcessInstanceID, ActivityGUID, ReadyTaskType) {
        var url = '@Url.Action("financePrint", "Form")' + "?ProcessGUID=" + ProcessGUID + "&&AppInstanceID=" + ProcessInstanceID + "&&ActivityGUID=" + ActivityGUID + "&&ReadyTaskType=" + ReadyTaskType;
        var width = screen.availWidth * 0.8;
        var top = screen.availWidth * 0.05;
        var left = screen.availWidth * 0.1;
        var height = screen.availHeight * 0.8;
        window.open(url, "", "width=" + width + "px, height=" + height + "px, top=" + top + "px, left=" + left + "px");
    }
    function EnterClick(va)
    {
        if(va==13)
        {
            onRefresh()
        }
    }
     function onRefresh() {
         var grid = $("#grid").data("kendoGrid");
         grid.dataSource.read();
     }
     function addUsers() {
         var url = '@Url.Action("EmployeeSelect", "Employee")';
         OpenSelectUserPop(url,RefreshValue);
     }
    function RefreshValue(selectPostList)
    {
        if (selectPostList != null || selectPostList != undefined) {
            var strNames = "";
            var strUserIDs = "";
            $.each(selectPostList, function (i, val) {
                strNames = val.Name;
                strUserIDs = val.UserID;
                $("#txtUsersName").val(strNames);
                $("#txtUsersID").val(strUserIDs);
            });
        }
    }


    function SelectDeparment(valtag, textTag) {
        var url = '@Url.Action("UCDepartmentSelect", "Form")';
           window.top.winObj = window;
           window.top.refresh = function (vals, txts) {
               $(valtag).val(vals);
               $(textTag).val(txts);
           };
           window.top.oDG = $.dialog({
               lock: true,
               background: '#FFF',
               opacity: 0.5,
               id: 'esDialog',
               title: '部门选择',
               titleAlign: 'left',
               content: "url:" + url,
               width: 570,
               height: 300,
               btnBar: false,
               lockScroll: true
           });
       }
     function onClear() {
         $("#frm").reset();
     }
     function loadData() {
         $("#grid").kendoGrid({
             selectable: "multiple,row",
             dataSource: {
                 serverPaging: true,
                 pageSize: @FCDB.Web.Helpers.AppSettings.DefaultPageSize,
                 transport: {
                     read: {
                         url: '@Url.Action("financePrint", "ReadyTasks")',
                         type: "POST",
                         dataType: "json",
                         data: {
                             dtStart: function () {
                                 return $("#txtStartDate").val();
                             },
                             dtEnd: function () {
                                 return $("#txtEndDate").val();
                             },
                             keyword: function () {
                                 return $("#txtAppName").val();
                             },
                             UserIDs: function () {
                                 return $("#txtUsersID").val();
                             },
                             DeparmentID: function () {
                                 return $("#txUsersDepartmentID").val();
                             },
                             ProcessGUID:function()
                             {
                                 return $("#dpProcessList").val();
                             }
                         }
                     }
                 },
                 schema: {
                     model: {
                         fields: {
                             CreatedDateTime: { type: "date" },
                             AppInstanceCreateTime: { type: "date" }
                         }
                     },

                     data: function (d) { return d.Data; },
                     //取出資料總筆數(計算頁數用)
                     total: function (d) { return d.TotalCount; }
                 }
             },
             height: 600,

             pageable: {
                 refresh: true,
                 pageSizes: true
             },
             dataBinding: function (e) {
                 for (var i = 0; i < e.items.length; i++) {
                     e.items[i].CreatedDateTime = company(e.items[i].CreatedDateTime);
                     e.items[i].AppInstanceCreateTime = company(e.items[i].AppInstanceCreateTime);
                 }
             },
             rowTemplate: kendo.template($("#rowTemplate").html())
         });
     }

     $(function () {
         loadData();
         $("#txtStartDate").kendoDatePicker({ format: "yyyy-MM-dd" });
         $("#txtEndDate").kendoDatePicker({ format: "yyyy-MM-dd" });
         var viewDetail = '@Request["ViewFormDetail"]';
         if (viewDetail != "") {
             var width = screen.availWidth * 0.8;
             var height = screen.availHeight * 0.8;
             window.open(url, "", "dialogWidth=" + width + "px;dialogHeight=" + height + "px;center:yes;");
             // OpenPop(url, "任务查看");
         }
     });
    function company(CreatedDateTime) {
        var now = new Date(CreatedDateTime);
        var year = now.getFullYear();       //年
        var month = now.getMonth() + 1;     //月
        var day = now.getDate();            //日

        var hh = now.getHours();            //时
        var mm = now.getMinutes();          //分

        var clock = year + "-";

        if (month < 10)
            clock += "0";
        clock += month + "-";

        if (day < 10)
            clock += "0";

        clock += day + " ";

        if (hh < 10)
            clock += "0";

        clock += hh + ":";
        if (mm < 10) clock += '0';
        clock += mm;
        return clock;
    }
</script>
